package com.gollum.web.controller.monitor;

import com.alibaba.fastjson2.JSONObject;
import com.gollum.common.annotation.AddOperateLog;
import com.gollum.common.domain.response.RestResponse;
import com.gollum.common.enums.BusinessType;
import com.gollum.common.web.controller.BaseController;
import com.gollum.system.domain.request.SysLogininforRequest;
import com.gollum.system.service.SysLogininforService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;


/**
 * 登录信息controller
 *
 * @author Herther
 * @createTime 2022年09月06日 23:05:00
 * @since 1.0.0
 */
@Api(tags = "系统监控中心-登录信息")
@RestController
@RequestMapping("/logininfor")
public class SysLogininforController extends BaseController {


    @Autowired
    protected SysLogininforService sysLogininforService;

    @PostMapping("/list")
    @ApiOperation(value = "分页查询登录信息")
    public RestResponse listPage(@RequestBody JSONObject jsonObject) {
        buildPageQuery(jsonObject);
        SysLogininforRequest sysLogininforRequest = this.toJavaObjectParams(SysLogininforRequest.class, jsonObject);
        return RestResponse.success(sysLogininforService.listPage(sysLogininforRequest));
    }


    @GetMapping("/get/{id}")
    @ApiOperation(value = "获取登录信息详情")
    public RestResponse getDetail(@PathVariable("id") Long id) {
        return RestResponse.success(sysLogininforService.getDetailById(id));
    }

    @DeleteMapping("/remove/{id}")
    @ApiOperation(value = "删除登录详情")
    @AddOperateLog(title = "删除登录详情",code = "MONITOR",businessType = BusinessType.DELETE)
    public RestResponse remove(@PathVariable("id") Long[] ids) {
        sysLogininforService.removeByIds(Arrays.asList(ids));
        return RestResponse.success().setMsg("删除成功");
    }

}
